#include "RsGisLibUtiImgBandRasterZonetoHDF.h"
#include "ExtensionManager.h"
#include "ExtensionSession.h"
#include <QVariant>

RsGisLibUtiImgBandRasterZonetoHDF::RsGisLibUtiImgBandRasterZonetoHDF(RsgisPortal* ClientPortal, QWidget *parent)
{
	ui = new Ui::RsGisLibUtiImgBandRasterZonetoHDF();
	ui->setupUi(this);

	Portal = ClientPortal;

	connect(ui->pushButton_InputFilePath, SIGNAL(clicked()), this, SLOT(on_action_Button_InputFilePath_clicked()));
	connect(ui->pushButton_MaskFilePath, SIGNAL(clicked()), this, SLOT(on_action_Button_MaskFilePath_clicked()));
	connect(ui->pushButton_BandFilePath, SIGNAL(clicked()), this, SLOT(on_action_Button_BandFilePath_clicked()));
	connect(ui->pushButton_OutputFilePath, SIGNAL(clicked()), this, SLOT(on_action_Button_OutputFilePath_clicked()));
	connect(ui->pushButton_Excecute, SIGNAL(clicked()), this, SLOT(on_action_Button_Excecute_clicked()));

	ui->lineEdit_InputFilePath->setText("D:\\RS-RPC\\TEST\\IN\\RsGisLib\\In");
	ui->lineEdit_MaskFilePath->setText("D:\\RS-RPC\\TEST\\IN\\RsGisLib\\In");
	ui->lineEdit_BandFilePath->setText("D:\\RS-RPC\\TEST\\IN\\RsGisLib\\In");
	ui->lineEdit_OutputFilePath->setText("D:\\RS-RPC\\TEST\\IN\\RsGisLib\\Out");

	ui->lineEdit_maskVal->setText("0.0");

	ui->lineEdit_Priority->setText("16");
}

void RsGisLibUtiImgBandRasterZonetoHDF::on_action_Button_InputFilePath_clicked()
{
	QString str = QFileDialog::getOpenFileName(this, "File Explorer", QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation), "All file(*.*)");
	ui->lineEdit_InputFilePath->setText(str.toUtf8());
}

void RsGisLibUtiImgBandRasterZonetoHDF::on_action_Button_MaskFilePath_clicked()
{
	QString str = QFileDialog::getOpenFileName(this, "File Explorer", QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation), "All file(*.*)");
	ui->lineEdit_InputFilePath->setText(str.toUtf8());
}

void RsGisLibUtiImgBandRasterZonetoHDF::on_action_Button_BandFilePath_clicked()
{
	QString str = QFileDialog::getOpenFileName(this, "File Explorer", QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation), "All file(*.*)");
	ui->lineEdit_BandFilePath->setText(str.toUtf8());
}

void RsGisLibUtiImgBandRasterZonetoHDF::on_action_Button_OutputFilePath_clicked()
{
	QString str = QFileDialog::getSaveFileName(this, "File Explorer", QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation), "All file(*.*)");
	ui->lineEdit_OutputFilePath->setText(str.toUtf8());
}

void RsGisLibUtiImgBandRasterZonetoHDF::on_action_Button_Excecute_clicked()
{
	QList<QVariant> SysParaList;
	SysParaList << QVariant(QString("RsGisLib"));
	SysParaList << QVariant(QString("ImageUtils"));
	SysParaList << QVariant(int(ui->lineEdit_Priority->text().toInt()));

	QList<QVariant> AlgParaList;
	AlgParaList << QVariant(QString("ImgBandRasterZonetoHDF"));
	AlgParaList << QVariant(QString(ui->lineEdit_InputFilePath->text()));
	AlgParaList << QVariant(QString(ui->lineEdit_BandFilePath->text()));
	AlgParaList << QVariant(QString(ui->lineEdit_MaskFilePath->text()));
	AlgParaList << QVariant(QString(ui->lineEdit_OutputFilePath->text()));
	AlgParaList << QVariant(double(ui->lineEdit_maskVal->text().toDouble()));

	QVariantList ArgList;
	ArgList << (QVariant)SysParaList;
	ArgList << (QVariant)AlgParaList;

	Portal->goAhead(ArgList);
}